package com.yobol.jgrowth.service.impl;

import com.yobol.jgrowth.domain.Article;
import com.yobol.jgrowth.mapper.ArticleMapper;
import com.yobol.jgrowth.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Implement Article Service
 *
 * @author
 * @create 2018-04-04 18:06
 **/

@Service
public class ArticleServiceImpl implements ArticleService {

    @Autowired
    ArticleMapper articleMapper;

    @Override
    public int addArticle(Article article) {
        return articleMapper.insert(article);
    }

    @Override
    public List<Article> getArticlesByTag(String tag) {
        return articleMapper.getArticlesByTag(tag);
    }

    @Override
    public List<Article> getArticlesByUsername(String username) {
        return articleMapper.getArticlesByUsername(username);
    }

    @Override
    public Article getArticleByAid(int aid) {
        return articleMapper.getArticleByAid(aid);
    }

    @Override
    public int deleteArticleByAid(int aid) {
        return articleMapper.deleteArticleByAid(aid);
    }

    @Override
    public int updateArticleByPrimaryKey(Article article) {
        return articleMapper.updateArticleByPrimaryKey(article);
    }

    @Override
    public List<Article> getArticlesByKeywords(String keywords) {
        return articleMapper.getArticlesByKeywords(keywords);
    }

    @Override
    public int updateArticleCommentedCtr(Article article) {
        return articleMapper.updateArticleCommentedCtr(article);
    }

    @Override
    public int updateArticleScannedCtr(Article article) {
        return articleMapper.updateArticleScannedCtr(article);
    }

    @Override
    public List<Article> getArticlesOfBanner(int num) {
        return articleMapper.getArticlesByCtrRatio(num);
    }

    @Override
    public List<Article> getArticlesByTagRank(String tag, int num) {
        return articleMapper.getArticlesByTagRank(tag,num);
    }
}
